<template>
  <div class="JNPF-common-layout">
    <div class="JNPF-common-layout-center">
      <el-row class="JNPF-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="验收日期">
              <el-date-picker v-model="fbillcredate" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
                start-placeholder="开始日期" end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="单据编号">
              <el-input v-model="listQuery.fbillno" placeholder="单据编号" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="加盟商">
              <el-select v-model="listQuery.fcustomno" placeholder="请选择"
                :disabled="$store.getters.userInfo.manufacturer">
                <el-option v-for="item in customlist" :key="item.FCUSTOMNO" :label="item.FCUSTOMNAME"
                  :value="item.FCUSTOMNO">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="6">
              <el-form-item label="单据状态">
                <el-select v-model="listQuery.fbillstate" placeholder="请选择">
                  <el-option v-for="item in statuslist" :key="item.id" :label="item.fullName" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </template>
          <el-col :span="6">
            <el-form-item label="">
              <el-button type="primary" icon="el-icon-search" >查询</el-button>
              <el-button type="primary" icon="el-icon-plus" @click="insert(undefined)">新增</el-button>
              <el-button type="success" icon="el-icon-download">导出</el-button>
              <el-button type="info" icon="el-icon-printer">打印</el-button>
              <el-button type="text" icon="el-icon-arrow-down" @click="showAll = true" v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll = false" v-else>
                收起</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="JNPF-common-layout-main JNPF-flex-main">
        <JNPF-table :data="list" border v-loading="loading">
          <el-table-column prop="FBILLNO" label="单据编号" width="150"></el-table-column>
          <el-table-column prop="FCUSTOMNAME" label="加盟商名称" min-width="120"></el-table-column>
          <el-table-column prop="FBILLCREDATE" label="订货日期" width="150">
            <template slot-scope="scope">
              {{ jnpf.dateFormat(scope.row.FBILLCREDATE, "YYYY-MM-DD") }}
            </template>
          </el-table-column>
          <el-table-column prop="FITEMCOUNT" label="品项数" width="90"></el-table-column>
          <el-table-column prop="FPIECECOUNT" label="总件数" width="90"></el-table-column>
          <el-table-column prop="FTOTNOAMT" label="未税金额" width="100"></el-table-column>
          <el-table-column prop="FTOTTAXAMT" label="税额" width="100"></el-table-column>
          <el-table-column prop="FTOTAMT" label="含税金额" width="100"></el-table-column>
          <el-table-column prop="FDISAMT" label="配送金额" width="100"></el-table-column>
          <el-table-column prop="FPROMAMT" label="优惠金额" width="100"></el-table-column>
          <el-table-column prop="FBILLTYPE" label="单据类型" width="110"></el-table-column>
          <el-table-column prop="FBILLSTATE" label="单据状态" width="100">
            <template slot-scope="scope">
              {{ scope.row.FBILLSTATE | dynamicText(statuslist) }}
            </template>
          </el-table-column>
          <el-table-column prop="fexplanation" label="备注"></el-table-column>
          <el-table-column fixed="left" label="操作" align="center" width="200">
            <template slot-scope="scope">
              <el-button type="text" @click="insert(scope.row.FBILLNO)" size="small" icon="el-icon-edit">
                编辑
              </el-button>
              <!-- <el-button slot="reference" icon="el-icon-delete" style="color: red;margin:0 10px;"
                @click="Orderdelete(scope.row.FBILLNO)" type="text">删除</el-button> -->
              <el-button slot="reference" icon="el-icon-s-check" style="color: orange;margin:0 10px;"
                @click="ConfirmOrder(scope.row)" type="text">审核</el-button>
            </template>
          </el-table-column>
        </JNPF-table>
        <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"/>
        <Form ref="Form"  :formationlist="customlist" />
      </div>
    </div>
  </div>
</template>
<script>
  import Form from "./Form.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    name: 'shop',
    components: { Form },
    data() {
      return {
        showAll: false,
        statuslist: [
          {
            id: 1, fullName: '未确认'
          },
          {
            id: 2, fullName: '已确认'
          }
        ],
        fdistypelist: [
          {
            id: '1', fullName: '直送'
          },
          {
            id: '2', fullName: '自提'
          }
        ],
        customlist:[
          {
            "FCUSTOMNO": "1001",
            "FCUSTOMNAME": "冷链",
            "FCUSTOMTYPE": 1,
            "FCUSTOMLEVEL": 12,
            "FLEADER": "121",
            "FPHONE": "12",
            "FEMAIL": "2121",
            "FCITY": "121",
            "FAREA": "1212",
            "FADDRESS": null,
            "FDISAREA": 0,
            "FDISMONEY": 0,
            "FCREDITMONEY": 0,
            "FBUYER": "admin",
            "FSTATE": 1,
            "FCREDATE": null,
            "FOPERATOR": null,
            "FOPERDATE": null,
            "itemCount": 0
          },
        ],
        list: [
            {
              "begindate": null,
              "enddate": null,
              "FBILLNO": "HO241101000012",
              "FCUSTOMNO": "1001",
              "FBILLCREDATE": "2024-11-01T00:00:00.000+00:00",
              "FDISDATE": "2024-11-01T00:00:00.000+00:00",
              "FDISTYPE": 0,
              "FITEMCOUNT": 6,
              "FPIECECOUNT": 1018,
              "FTOTNOAMT": 820.48,
              "FTOTTAXAMT": 131.28,
              "FTOTAMT": 951.76,
              "FDISAMT": 1097.28,
              "FPROMAMT": 0,
              "FPAYAMT": 0,
              "FPAYBILLNO": null,
              "FSALEER": "admin",
              "FEXPLANATION": null,
              "FBILLTYPE": 0,
              "FBILLSTATE": 1,
              "FOPERATOR": "admin",
              "FOPERDATE": null,
              "FCHECKER": null,
              "FCHECKDATE": null,
              "FCUSTOMNAME": "冷链",
              "jM_ORD_DETAIL": null
            },
        ],
        fbillcredate: [jnpf.dateFormat(new Date(), "YYYY-MM-DD"), jnpf.dateFormat(new Date(), "YYYY-MM-DD")],
        loading: false,
        total: 0,
        listQuery: {
          page: 1,
          limit: 20,
          sort: "desc",
          sidx: "",
          fbillstate: "",
          fbillno: "",
          begindate: undefined,
          enddate: undefined,
          fcustomno: ""
        },
      };
    },
    computed: {},
    methods: {
      insert(id) {
        this.$refs.Form.init(id);
      },
    },
  };
</script>